import type { ColumnsType, ColumnType } from "ant-design-vue/es/table";

export type State = "edit" | "view" | "commit";
export type Buttons = "edit" | "save" | "add" | "copy" | "remove" | "slots";

export type TableSignal = {
  __id__: string;
  __state__: State;
};

export type WithTableSignal<T> = T & TableSignal;

export type SetTableDataConfig = {
  [key in Exclude<keyof TableSignal, "__id__">]?: TableSignal[key];
};

export type DataIndex<T> = keyof T | "operation";

export type Component =
  | "input"
  // | "input-number"
  | "select"
  // | "cascader"
  | "date-picker";

export interface BsColumn<T> {
  title: string;
  dataIndex: DataIndex<T>;
  width?: number | string;
  constant?: boolean; // 不可修改
  inputType?: {
    is: Component;
    type?: string;
    options?: any[];
    [property: string]: unknown;
  };
}

export interface Column<T> extends ColumnType {
  // title: string;
  // dataIndex: DataIndex<T>;
  width?: number | string;
  constant?: boolean; // 不可修改
  inputType?: {
    is: Component;
    type?: string;
    options?: any[];
    [property: string]: unknown;
  };
}

export type Columns<T = unknown> = Column<T>[];

export interface HandleEvent {
  text: string | number;
  column: Column<any>;
  record: WithTableSignal<any>;
  index: number;
}
